package com.zy.controller;

import com.github.pagehelper.PageInfo;
import com.zy.server.UserService;
import com.zy.pojo.User;
import com.zy.utils.MyUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import java.awt.*;
import java.util.List;

/**
 * @author: 11473
 * @time: 2019/9/27 16:18
 */
@Controller
public class UserController {

    @Autowired
    UserService userService;


    /**
     * 查询用户 分页返回
     * @param pageIndex 用户索引
     * @param pageSize  一次显示的大小
     * @param modelAndView modelAndView
     * @return
     */
    @RequestMapping("/page")
    public ModelAndView login(@RequestParam(required = false, defaultValue = "1") Integer pageIndex,
                        @RequestParam(required = false, defaultValue = "5") Integer pageSize,
                              ModelAndView modelAndView){

        List<User> user = userService.select(pageIndex, pageSize).getList();
        modelAndView.setViewName("userPage");
        modelAndView.addObject("user", user);
        return modelAndView;
    }
}
